package our.pack;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

public class MediaViewTextActivity extends Activity{
	
	private TextView message;
	private String PATH;
	
	/**
	 * show a textfile
	 */
	
	public void onCreate(Bundle SaveInstanceState){
		super.onCreate(SaveInstanceState);
		setContentView(R.layout.media_view_text);
		
		//getting the filePath
		Intent i = getIntent();
		Bundle b = i.getExtras();
		PATH = (String) b.get("PATH");
		File file = new File(PATH);
		
		//make the file into a string
		StringBuilder sb = new StringBuilder();
		String line;
		try {
			BufferedReader reader = new BufferedReader(new FileReader(file));
		    while ((line = reader.readLine()) != null) {
		        sb.append(line);
		    }
		    
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		//show the text
		message = (TextView) findViewById(R.id.mediaViewTextMessage);
		message.setText(sb.toString());
		
		
		
	}

}
